package br.ufmg.dees.insane.ui.rich.learn.learn_view.equation_view.command;

import java.io.StringWriter;

import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;

public final class HtmlFormatter {
    
    public static String format(String str) {
        HTMLEditorKit c= new HTMLEditorKit();
        HTMLDocument doc=(HTMLDocument)c.createDefaultDocument();
        try {
            StringWriter sw = new StringWriter();
            c.read(new java.io.StringReader(str),doc,0);
            c.write(sw,doc,0,doc.getLength());
            return sw.toString();
        } catch(Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}